package com.dongxing.concyrrency.chapter10;

import java.util.concurrent.TimeUnit;

/**
 * @author XavierDong
 **/
public class SynchronizedProblem {

    public static void main(String[] args) {

        Thread t1 = new Thread() {
            @Override
            public void run() {
                SynchronizedProblem.run();
            }
        };

        t1.start();

        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        Thread t2 = new Thread() {
            @Override
            public void run() {
                SynchronizedProblem.run();
            }
        };

        t2.start();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        t2.interrupt();
        System.out.println(t2.isInterrupted());


    }

    private synchronized static void run() {

        System.out.println(Thread.currentThread());
        while (true) {

        }


    }
}
